package com.rsscollector.feedrss;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.apache.log4j.Logger;

import com.rsscollector.util.PersistenceUtil;

public class FeedReaderJob implements Job {
    	public static Logger logger = Logger.getLogger(FeedReaderJob.class
			.getName());
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("Begin FeedReaderJob");
        PersistenceUtil.begin();
        FeedReader.collectAndUpdateFeedData();
        PersistenceUtil.end();
        logger.info("End FeedReaderJob");

    }
/*
    public static Scheduler startFeedReader() {
        SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
        Scheduler sched = null;
        try {
            sched = schedFact.getScheduler();
            sched.start();
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
        JobDetail jobDetail = new JobDetail("FeedReaderJob",         // job name
                sched.DEFAULT_GROUP,   // job group (you can also specify 'null' to use the default group)
                FeedReaderJob.class);        // the java class to execute

        Trigger trigger = TriggerUtils.makeMinutelyTrigger(1000);
        trigger.setStartTime(new Date());
        trigger.setName("myTrigger");

        try {
            sched.scheduleJob(jobDetail, trigger);
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
        return sched;
    }
*/
}
